package com.zxmc.server.controller.user;

import com.zxmc.common.result.Result;
import com.zxmc.pojo.entity.Chapter;
import com.zxmc.pojo.vo.ChapterDirectoryVO;
import com.zxmc.server.service.ChapterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user/chapter")
@Slf4j
@Api(tags = "章节相关接口")
public class ChapterController {
    @Autowired
    private ChapterService chapterService;
    @ApiOperation("查看某一章内容")
    @GetMapping("/list")
    public Result<Chapter> list(Integer id, Integer chapterId) {
        log.info("查看某一章内容:{},{}", id, chapterId);
        return Result.success(chapterService.list(id, chapterId));
    }
    @ApiOperation("查看某一章内容(书架)")
    @GetMapping("/listOnly")
    public Result<Chapter> listOnly(Integer id, Integer chapterId) {
        log.info("查看某一章内容(书架):{},{}", id, chapterId);
        return Result.success(chapterService.listOnly(id, chapterId));
    }

    @ApiOperation("查看小说全部章节")
    @GetMapping("/directory")
    public Result<List<ChapterDirectoryVO>> directory(Integer id) {
        log.info("查看小说全部章节:{}", id);
        return Result.success(chapterService.directory(id));
    }
}
